﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using QLTV_Public;

namespace QLTV_Data
{
   public class DangKyCaBiet_Data
    {
       KetNoiCSDL_Data kn = new KetNoiCSDL_Data();
       public DataTable TaoBang(string sql)
       {
           return kn.taobang(sql);
       }
       public DataTable LayDuLieu()
       {
           return kn.LayDuLieu("Load_DangKyCaBiet");
       }
       public int Insert(DangKyCaBiet_Public soCaBiet, DangKyCaBiet_Public maTaiLieu, DangKyCaBiet_Public ngayDangKy, DangKyCaBiet_Public tinhTrangTL, DangKyCaBiet_Public trangThaiSD, DangKyCaBiet_Public trangThaiMuon)
       {
           int Npara = 6;
           string[] name = new string[Npara];
           object[]value=new object[Npara];
           name[0] = "@SoCaBiet";
           value[0] = soCaBiet.SoCaBiet;
           name[1] = "@MaTaiLieu";
           value[1] = maTaiLieu.MaTaiLieu;
           name[2] = "@NgayDangKy";
           value[2] = ngayDangKy.NgayDangKy;
           name[3] = "@TinhTrangTaiLieu";
           value[3] = tinhTrangTL.TinhTrangTaiLieu;
           name[4] = "@TrangThaiSuDung";
           value[4] = trangThaiSD.TrangThaiSuDung;
           name[5] = "@TrangThaiMuon";
           value[5] = trangThaiMuon.TrangThaiMuon;
           return kn.update("Insert_DangKyCaBiet",name,value,Npara);
       }
       public int Update(DangKyCaBiet_Public soCaBiet, DangKyCaBiet_Public maTaiLieu, DangKyCaBiet_Public ngayDangKy, DangKyCaBiet_Public tinhTrangTL, DangKyCaBiet_Public trangThaiSD, DangKyCaBiet_Public trangThaiMuon)
       {
           int Npara = 6;
           string[] name = new string[Npara];
           object[] value = new object[Npara];
           name[0] = "@SoCaBiet";
           value[0] = soCaBiet.SoCaBiet;
           name[1] = "@MaTaiLieu";
           value[1] = maTaiLieu.MaTaiLieu;
           name[2] = "@NgayDangKy";
           value[2] = ngayDangKy.NgayDangKy;
           name[3] = "@TinhTrangTaiLieu";
           value[3] = tinhTrangTL.TinhTrangTaiLieu;
           name[4] = "@TrangThaiSuDung";
           value[4] = trangThaiSD.TrangThaiSuDung;
           name[5] = "@TrangThaiMuon";
           value[5] = trangThaiMuon.TrangThaiMuon;
           return kn.update("Update_DangKyCaBiet", name, value, Npara);
       }
       public int Delete(DangKyCaBiet_Public soCaBiet)
       {
           int Npara = 1;
           string[] name = new string[Npara];
           object[] value = new object[Npara];
           name[0] = "@SoCaBiet";
           value[0] = soCaBiet.SoCaBiet;
           return kn.update("Delete_DangKyCaBiet", name, value, Npara);
       }
       public int Update_TinhTrangTL(DangKyCaBiet_Public tinhTrang, DangKyCaBiet_Public trangthai, DangKyCaBiet_Public soCaBiet)
       {
           int nPara = 3;
           string[] name = new string[nPara];
           object[] value = new object[nPara];
           name[0]="@TinhTrang";
           value[0] = tinhTrang.TinhTrangTaiLieu;
           name[1] = "@TrangThai";
           value[1] = trangthai.TrangThaiSuDung;
           name[2] = "@SoCaBiet";
           value[2] = soCaBiet.SoCaBiet;
           return kn.update("Update_TinhTrangTL",name,value,nPara);
       }
       public int Insert_DangKyTaoMaCaBiet(DangKyCaBiet_Public dk)
       {
           int n = 6;
           string[] name = new string[n];
           object[]value=new object[n];
           name[0]="@SoCaBiet";
           value[0]=dk.SoCaBiet;
           name[1]="@MaTaiLieu";
           value[1]=dk.MaTaiLieu;
           name[2]="@NgayDangKy";
           value[2]=dk.NgayDangKy;
           name[3]="@TrangThaiSuDung";
           value[3]=dk.TrangThaiSuDung;
           name[4] = "@TrangThaiMuon";
           value[4] = dk.TrangThaiMuon;
           name[5] = "@MaNhanVien";
           value[5] = dk.MaNhanVien;
           return kn.update("Insert_DangKyTaoMaCaBiet",name,value,n);
       }
    }
}
